define([
		'yf',
		'jquery',
		'underscore',
		'text!template/menuTpl.html',
		'text!../../common/template/proList.html',
		'Swiper',
		'Loader',
		'yfUtil',
		'JRoll'
	],
  // test
	function (yf, $, _, menuTpl, proListTpl, Swiper, Loader, yfUtil, JRoll) {
		var me, myLoader, jroll, page = 1;
		var main = {
			initialize: function () {
				myLoader = new Loader();
				me = this;
				setTimeout(function () {
					me.createMenu();
					me.createRecommend(1);
				}, 500);
				$.ajax({
					type:"get",
					url:"https://www.zhihu.com/r/answers/61769455/comments",
					async:true,
					success:function(data){
						console.log(data)
					}
				});
			},
			bindEvents: {
				"click .menuList": "clickMenu",
				"click #condition": "goCondition"
			},
			createMenu: function () {
				var menuInfo;
				yf.ajax({
					type: "get",
					url: "./data/menu.json",
					async: true,
					success: function (data) {
						myLoader.remove();
						menuInfo = data.data;
						me.$el.find('#wrapper').html(_.template($(menuTpl).html())({
							result: menuInfo
						}));
					},
					error: function () {
						myLoader.remove();
					}
				});
			},
			clickMenu: function (e) {
				var url = $(e.currentTarget).attr('data-url');
				yf.openWebPage(url);
			},
			createRecommend: function (page) {
				var url = "./data/recommend" + page + ".json";
				yf.ajax({
					type: "get",
					url: url,
					async: true,
					success: function (data) {
						myLoader.remove();
						proListData = data.data;
						var html = _.template($(proListTpl).html())({
							result: proListData
						});
						var innerHTML = me.$el.find('.js_recommend').html();
						innerHTML += html;
						me.$el.find('.js_recommend').html(innerHTML);
						//生成jroll
						if (!jroll) {
							jroll = new JRoll('.content', {
								bounce: true,
								scrollX: false
							});
							jroll.on("scrollEnd", function () {
								if (this.y === this.maxScrollY) {
									page++;
									main.createRecommend(page);
								}
							});
						}else{
							jroll.refresh();
						}
					},
					error: function () {
						var showToast = new ShowToast("已经加载全部");
					}
				});
			}
		}
		return main;
	});